package com.world.cat.model.generate;

import com.world.common.enums.YesNo;
import com.world.common.generate.auto.*;
import com.world.common.model.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;

@QClass(actions = {QClassAction.add, QClassAction.view, QClassAction.del, QClassAction.edit})
@Entity
@Table(name = "auto")
public class Auto extends BaseEntity {
    @Column(name = "name", nullable = false)
    @QField(name = "姓名", actions = {Action.edit, Action.query, Action.show}, queryType = QFieldQueryType.like, nullable = false)
    private String name;

    @QField(name = "年龄", type = QFieldType.text, actions = {Action.edit, Action.query, Action.show}, nullable = true)
    private Integer age;

    @QField(name = "性别", type = QFieldType.dict, dictValues = "{'male':'男','female':'女'}", actions = {Action.edit, Action.query, Action.show}, nullable = false)
    private String gender;

    @QField(name = "是否结婚", type = QFieldType.dict, dictValues = "{'YES':'是','NO':'否'}", actions = {Action.edit, Action.query, Action.show}, nullable = false)
    @Enumerated(EnumType.STRING)
    private YesNo ifMarried;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @QField(name = "生日", type = QFieldType.date, format = "yyyy-MM-dd", actions = {Action.edit, Action.query, Action.show}, nullable = true)
    private Date birthday;

    @Column(columnDefinition = "text")
    @QField(name = "个人简介", type = QFieldType.textarea, actions = {Action.edit, Action.show}, nullable = true)
    private String introduce;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public YesNo getIfMarried() {
        return ifMarried;
    }

    public void setIfMarried(YesNo ifMarried) {
        this.ifMarried = ifMarried;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getIntroduce() {
        return introduce;
    }

    public void setIntroduce(String introduce) {
        this.introduce = introduce;
    }
}
